// 绘制直线
import BaseElement from './element';
class Line extends BaseElement {
    constructor(opts) {
        super(opts);
    }

    draw(ctx) {
        this.beforDraw(ctx);
        let { x: x1, y: y1 } = this.points[0];
        let { x: x2, y: y2 } = this.points[1];

        if (parseInt(x1) === parseInt(x2)) {
            x1 = x2 = parseInt(x1) + this.offset;
        } else {
            y1 = parseInt(y1) + this.offset;
            y2 = parseInt(y2) + this.offset;
        }

        if (this.beginPath) {
            ctx.moveTo(x1, y1);
        }
        ctx.lineTo(x2, y2);
        this.afterDraw(ctx);
    }

    addPoint() {}
    update() {}
}
export default Line;
